Skip to content

Conversation

@Kludex
Copy link
Owner

@Kludex Kludex commented Jan 1, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds the ability to customize which content types should be excluded from gzip compression in GZipMiddleware. It introduces two new keyword-only parameters: excluded_content_types to completely replace the default exclusions, and additional_excluded_content_types to add more exclusions while keeping the defaults. Additionally, it expands the default excluded content types to include already-compressed formats.

Changes:

  • Added excluded_content_types and additional_excluded_content_types parameters to GZipMiddleware
  • Extended DEFAULT_EXCLUDED_CONTENT_TYPES to include application/zip, application/gzip, and application/x-gzip
  • Propagated the excluded_content_types parameter through IdentityResponder and GZipResponder

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to +24
excluded_content_types: tuple[str, ...] = DEFAULT_EXCLUDED_CONTENT_TYPES,
additional_excluded_content_types: tuple[str, ...] = (),
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new excluded_content_types and additional_excluded_content_types parameters lack test coverage. Consider adding tests that verify:

  1. Custom content types can be excluded from compression using excluded_content_types
  2. Additional content types can be excluded using additional_excluded_content_types
  3. The default excluded content types (application/zip, application/gzip, application/x-gzip) are properly excluded from compression

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +24
excluded_content_types: tuple[str, ...] = DEFAULT_EXCLUDED_CONTENT_TYPES,
additional_excluded_content_types: tuple[str, ...] = (),
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation in docs/middleware.md should be updated to describe the new excluded_content_types and additional_excluded_content_types parameters. The current documentation at lines 240-244 mentions the default exclusion behavior but doesn't document that these can now be customized.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +13
DEFAULT_EXCLUDED_CONTENT_TYPES = (
"text/event-stream",
"application/zip",
"application/gzip",
"application/x-gzip",
)
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding new content types to DEFAULT_EXCLUDED_CONTENT_TYPES is a breaking change. While it's sensible to exclude already-compressed formats (application/zip, application/gzip, application/x-gzip), this changes the default behavior for existing users. Consider documenting this as a breaking change in the release notes and ensuring it's mentioned in the PR description or migration guide.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants